// 
// average_background.h
//
// Author: vietcuong
// Description: create a background model bases on an average of consecutive frames
//

#ifndef _AVG_BACKGROUND_
#define _AVG_BACKGROUND_

#include "cv.h"
#include "highgui.h"
#include "cxcore.h"

class AverageBackground {
    private:
        IplImage *IavgF,
                 *IdiffF,
                 *IprevF;

        IplImage *IhighF,
                 *IlowF;

        IplImage *Iscratch,
                 *Iscratch2,
                 *Igray1,
                 *Igray2, 
                 *Igray3;

        IplImage *Ihigh1,
                 *Ihigh2,
                 *Ihigh3,
                 *Ilow1,
                 *Ilow2,
                 *Ilow3;

        IplImage *Imask_tmp;

        float frame_count;

    public:
        AverageBackground();
        void init(IplImage *image);
        void setScaleHigh(float scale);
        void setScaleLow(float scale);
        void accumulate_background(IplImage *image);
        void create_model();
        void find_foreground(IplImage *image, IplImage *Imask);
        void deallocate_images();
};

#endif
